/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.elookinto.sample;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

// Plain old Java Object it does not extend as class or implements 
// an interface
// The class registers its methods for the HTTP GET request using the @GET annotation. 
// Using the @Produces annotation, it defines that it can deliver several MIME types,
// text, XML and HTML. 
// The browser requests per default the HTML MIME type.
//Sets the path to base URL + /hello
// This method is called if XML is request
@Path("/hello")
public class Controller {

    // This method is called if TEXT_PLAIN is request
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String sayPlainTextHello() {
        return "Hello Jersey";
    }

    // This method is called if TEXT_PLAIN is request
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/test")
    public A testJSON() {
        A a = new A();
        a.setP("testing");
        return a;
    }

    class A {

        private String p;

        /**
         * Get the value of p
         *
         * @return the value of p
         */
        public String getP() {
            return p;
        }

        /**
         * Set the value of p
         *
         * @param p new value of p
         */
        public void setP(String p) {
            this.p = p;
        }
    }
}
